package com.zsp.utils.security_jwt;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.userdetails.User;

public class JwtAuthentication extends AbstractAuthenticationToken {

    private final User user; // 当前用户
    private final Object credentials; // 凭证，例如原始的 Token 本身

    public JwtAuthentication(User user, Object credentials) {
        super(user.getAuthorities());
        this.user = user;
        this.credentials = credentials;
        super.setAuthenticated(true); // 设置为已认证状态
    }

    @Override
    public Object getCredentials() {
        return credentials; // 返回凭证
    }

    @Override
    public Object getPrincipal() {
        return user; // 返回当前用户
    }
}
